/*
 * nativeactivity.cpp
 *
 *  Created on: 07 Nis 2012
 *      Author: hframe
 */

#include "nativeactivity.h"

namespace androidplus {
nativeactivity::nativeactivity() :
		child(NULL) {

}

nativeactivity::~nativeactivity() {
	LOGI("NativeActivity Destroying");
}
void nativeactivity::activity_on_start() {
	LOGI("activity on start called");

}
void nativeactivity::activity_on_stop() {
	LOGI("activity on stop called");

}
void nativeactivity::activity_on_resume() {
	LOGI("activity on resume called");

}
void nativeactivity::activity_on_destroy() {

}
void nativeactivity::activity_on_pause() {

}
void nativeactivity::activity_on_configuration_changed() {

}
void nativeactivity::activity_before_destroy() {
	if (child != NULL)
		delete child;
}

void nativeactivity::activity_on_window_destroyed() {
	surface::uninitialize();
}
void nativeactivity::activity_on_window_created() {
	surface::initialize(cur_native_window());
	initialize_graphics_matrix();

}

void nativeactivity::render() {
	surface::draw_background();
	if (child != NULL)
		child->render_to(this);
	surface::flush();

}
void nativeactivity::on_event_touch_move(
		const input::event::motion_event *event) {

	LOGI("downtime:%ld", event->get_downtime());
	LOGI("edgeflags:%d", event->get_edgeflags());
	LOGI("eventtime:%ld", event->get_eventtime());
	LOGI("flags:%d", event->get_flags());
	LOGI("pointercount:%ld", event->get_pointercount());
	LOGI("historysize:%d", event->get_historysize());
	LOGI("metastate:%d", event->get_metastate());

	for (int i = 0; i < event->get_pointercount(); ++i) {
		LOGI("orientation[%d]:%f\n", i, event->get_orientation()[i]);
		LOGI("pressure[%d]:%f\n", i, event->get_pressure()[i]);
		LOGI("pointerid[%d]:%d\n", i, event->get_pointerid()[i]);
		LOGI("rawx[%d]:%f\n", i, event->get_rawx()[i]);
		LOGI("rawy[%d]:%f\n", i, event->get_rawy()[i]);
		LOGI("size[%d]:%f\n", i, event->get_size()[i]);
		LOGI("toolmajor[%d]:%f\n", i, event->get_toolmajor()[i]);
		LOGI("toolminor[%d]:%f\n", i, event->get_toolminor()[i]);
		LOGI("touchmajor[%d]:%f\n", i, event->get_touchmajor()[i]);
		LOGI("touchminor[%d]:%f\n", i, event->get_touchminor()[i]);
		LOGI("x[%d]:%f\n", i, event->get_x()[i]);
		LOGI("y[%d]:%f\n", i, event->get_y()[i]);
	}

	LOGI("xoffset:%f\n", event->get_xoffset());

	LOGI("xprecision:%f\n", event->get_xprecision());

	LOGI("yoffset:%f\n", event->get_yoffset());

	LOGI("yprecision:%f\n", event->get_yprecision());
	LOGI("************************\n");
}

}

